Skip to content

[SoftCSA] Fix 100% CPU usage and missing CWs on softcam restart#3709

Merged
jbleyel merged 1 commit intoopenatv:masterfrom
WXbet:fix-softcsa
Feb 15, 2026
Merged

[SoftCSA] Fix 100% CPU usage and missing CWs on softcam restart#3709
jbleyel merged 1 commit intoopenatv:masterfrom
WXbet:fix-softcsa

Conversation

@WXbet
Copy link
Contributor

@WXbet WXbet commented Feb 15, 2026

CPU bug: When the softcam restarts, the old socket gets closed but read() returning 0 (EOF) was never handled in the CWHandler poll loop. Additionally, POLLHUP was gated behind !(revents & POLLIN) which fails when both flags are set on a closed socket. This caused an infinite busy-loop: poll() -> read() -> 0 -> ignored -> poll() -> ...

Fix: Handle EOF (read==0) for both softcam_fd and proxy_fd paths, and remove the POLLIN gate from POLLHUP/POLLERR handling.

CW bug: After softcam reconnect, the running channel never received new CW keys. On reconnect (m_protocol3_established), distributeCAPMT() was called before the Protocol-3 handshake, sending CAPMTs in legacy format. The softcam processed these and started descrambling. The subsequent Protocol-3 CAPMTs after SERVER_INFO were treated as duplicates - no CW keys were sent.

Fix: On Protocol-3 reconnect, complete the handshake first before distributing CAPMTs. processServerInfoPacket() already calls distributeCAPMT() after the handshake completes.

Fixes #3708

CPU bug: When the softcam restarts, the old socket gets closed but
read() returning 0 (EOF) was never handled in the CWHandler poll loop.
Additionally, POLLHUP was gated behind !(revents & POLLIN) which fails
when both flags are set on a closed socket. This caused an infinite
busy-loop: poll() -> read() -> 0 -> ignored -> poll() -> ...

Fix: Handle EOF (read==0) for both softcam_fd and proxy_fd paths, and
remove the POLLIN gate from POLLHUP/POLLERR handling.

CW bug: After softcam reconnect, the running channel never received
new CW keys. On reconnect (m_protocol3_established), distributeCAPMT()
was called before the Protocol-3 handshake, sending CAPMTs in legacy
format. The softcam processed these and started descrambling. The
subsequent Protocol-3 CAPMTs after SERVER_INFO were treated as
duplicates - no CW keys were sent.

Fix: On Protocol-3 reconnect, complete the handshake first before
distributing CAPMTs. processServerInfoPacket() already calls
distributeCAPMT() after the handshake completes.
@WXbet WXbet changed the title [CWHandler] Fix 100% CPU usage and missing CWs on softcam restart [SoftCSA] Fix 100% CPU usage and missing CWs on softcam restart Feb 15, 2026
@jbleyel jbleyel merged commit 9fb2f55 into openatv:master Feb 15, 2026
3 of 4 checks passed
@WXbet WXbet deleted the fix-softcsa branch February 15, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Hight CPU usage

2 participants

Comments